<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>手术记录</title>
    <%- include('../_global/baseLibsJKDA') %>
    <%- include('../_global/baseLibs') %>
    <link rel="stylesheet" href="/static/css/jkda/public.css"/>
    <link rel="stylesheet" href="/static/css/jkda/page-main.css"/>
    <!--<link rel="stylesheet" href="/static/css/public.css">-->

<style type="text/css">
html,body {
	width: 100%;
	height: 100%;
	margin: 0px;
}
#ListTabBox .tab{ display: block!important;}
</style>



</head>

<body>
<!--<header class="header-box grey fixed">-->
    <!--<div class="header-content">-->
        <!--<div class="left-tool">-->
            <!--<a class="back" href="javascript:void(0);"><i class="iconfont icon-back"></i></a>-->
        <!--</div>-->

        <!--<div class="title">门诊记录详情</div>-->
    <!--</div>-->
<!--</header>-->
  <!-- <div class="search-nav">
    <i class="search"></i>
    <input type="text" placeholder="输入检查单号" id="JCDH" onkeyup="filterContent()">
  </div> -->
  <div id="ListTabBox">
    <div class="tab"> <div class="mz-list"  >
      <ul id= "ssjl" ></ul></div></div>
  </div> 
</body>
<script type="text/javascript">

    var page_ssjl = (function($, page_ssjl) {


        function indata(){
            var zxwyh = $.QuickUrlUtils.getRequest("ZXWYH");
            $.QuickRemote.AjaxJson(goal_jkda_service+"/jkda/queryJkdaSsjl", page_ssjl.queryJkdaJyjlBack,{ZXWYH: zxwyh});
        }
        //手术报告回调
        function queryJkdaJyjlBack(result){
            var rid;
            var bgzy;
            var bglx;
            var res = [];
            if(result){

                $(result).each(function(index,value){
                    var num = index;
                    if(rid){
                        if(this["RID"] == rid){
                            if(num == result.length-1){
                                bgzy += this["BGZY"];
                                res.push({BGZY:bgzy,RID:rid,BGLX:bglx});
                            }else{
                                bgzy += this["BGZY"];
                            }
                        }else{
                            if(num == result.length-1){
                                res.push({BGZY:bgzy,RID:rid,BGLX:bglx});
                                res.push({BGZY:this["BGZY"],RID:this["RID"],BGLX:this["BGLX"]});
                            }else{
                                res.push({BGZY:bgzy,RID:rid,BGLX:bglx});
                                rid = this["RID"];
                                bgzy = this["BGZY"];
                                bglx = this["BGLX"];
                            }
                        }
                    }else{
                        if(num == result.length-1){
                            res.push({BGZY:this["BGZY"],RID:this["RID"],BGLX:this["BGLX"]});
                        }else{
                            rid = this["RID"];
                            bgzy = this["BGZY"];
                            bglx = this["BGLX"];
                        }
                    }
                });
            }
            page_ssjl.appendToSsjl(res);
        }

        function sortNumber(a,b) {
            return b - a;
        }

        //创建手术报告信息
        function appendToSsjl(result){
            var lis = [];
            if(result.length != 0 ){
                var resultBak =result.sort(page_ssjl.sortNumber);
                $(resultBak).each(function(index){
                    var num = index;
                    if(this["BGLX"]=="C0001.0503"){
                        var bgzys = this["BGZY"].split("}|{");
                        // $(bgzys).each(function(){
                        var ssbgzy = bgzys[0].split("^|^");
                        var ssmc = ssbgzy[0];
                        var ssys = ssbgzy[3];
                        var sszs = ssbgzy[4];
                        var sssj = ssbgzy[1];
                        var ssmxh = ssbgzy[7];
                        var li= $("<li>");
                        var div = $("<a>");
                        div.attr("class", "li-box");
                        var div5 = $("<div>");
                        div5.attr("class", "black-block");
                        var span9 = $("<span>");
                        span9.html("手术明细号：" );
                        span9.appendTo(div5);
                        var span10 = $("<span>");
                        span10.html(ssmxh);
                        span10.appendTo(div5);
                        div5.appendTo(div);

                        var div1 = $("<div>");
                        div1.attr("class", "black-block");
                        var span1 = $("<span>");
                        span1.html("手术名称：" );
                        span1.appendTo(div1);
                        var span2 = $("<span>");
                        span2.html(ssmc);
                        span2.appendTo(div1);
                        div1.appendTo(div);

                        var div2 = $("<div>");
                        div2.attr("class", "black-block");
                        var span3 = $("<span>");
                        span3.html("手术医生：" );
                        span3.appendTo(div2);
                        var span4 = $("<span>");
                        span4.html(ssys);
                        span4.appendTo(div2);
                        div2.appendTo(div);

                        var div3 = $("<div>");
                        div3.attr("class", "black-block");
                        var span5 = $("<span>");
                        span5.html("助手：" );
                        span5.appendTo(div3);
                        var span6 = $("<span>");
                        span6.html(sszs);
                        span6.appendTo(div3);
                        div3.appendTo(div);

                        var div4 = $("<div>");
                        div4.attr("class", "black-block");
                        var span7 = $("<span>");
                        span7.html("日期：" );
                        span7.appendTo(div4);
                        var span8 = $("<span>");
                        sssj = sssj.replace(/\s/g,"");
                        var sj = sssj.substr(8,sssj.length);
                        sssj = sssj.substr(0,8);
                        var str;
                        var date;
                        if(StringUtils.isEmpty(sssj)){
                            str = sssj;
                        }else{
                            date = new Date(sssj.replace(/(\d{4})(\d{2})(\d{2})/g,'$1-$2-$3'));
                            str = date.Format("yyyy-MM-dd");
                        }
                        span8.html(str+" "+sj);
                        // span8.html(sssj);
                        span8.appendTo(div4);
                        div4.appendTo(div);

                        div.data("info",result[num]["BGZY"]);
                        div.on("click",function(){
                            var info = $(this).data("info");
                            StoreCache.setCache("jkdaSsjlCache", info+"^^mz");
                            $.QuickUrlUtils.redirectJSBridge({url:jkda_view+"/ssjl/ssjlDetail.ejs", title:"手术记录详情"});
                        });
                        div.appendTo(li);

                        lis.push(li);

                        // 	});

                    }else if(this["BGLX"]=="C0002.0503"){
                        var bgzys = this["BGZY"].split("}|{");
                        // $(bgzys).each(function(){
                        var ssbgzy = bgzys[0].split("^|^");
                        var ssmc = ssbgzy[1];
                        var ssys = ssbgzy[2];
                        var sszs = ssbgzy[3];
                        var sssj = ssbgzy[0];
                        var ssmxh = ssbgzy[5];
                        var li= $("<li>");
                        var div = $("<a>");
                        div.attr("class", "li-box");
                        var div5 = $("<div>");
                        div5.attr("class", "black-block");
                        var span9 = $("<span>");
                        span9.html("手术明细号：" );
                        span9.appendTo(div5);
                        var span10 = $("<span>");
                        span10.html(ssmxh);
                        span10.appendTo(div5);
                        div5.appendTo(div);

                        var div1 = $("<div>");
                        div1.attr("class", "black-block");
                        var span1 = $("<span>");
                        span1.html("手术名称：" );
                        span1.appendTo(div1);
                        var span2 = $("<span>");
                        span2.html(ssmc);
                        span2.appendTo(div1);
                        div1.appendTo(div);

                        var div2 = $("<div>");
                        div2.attr("class", "black-block");
                        var span3 = $("<span>");
                        span3.html("手术医生：" );
                        span3.appendTo(div2);
                        var span4 = $("<span>");
                        span4.html(ssys);
                        span4.appendTo(div2);
                        div2.appendTo(div);

                        var div3 = $("<div>");
                        div3.attr("class", "black-block");
                        var span5 = $("<span>");
                        span5.html("助手：" );
                        span5.appendTo(div3);
                        var span6 = $("<span>");
                        span6.html(sszs);
                        span6.appendTo(div3);
                        div3.appendTo(div);

                        var div4 = $("<div>");
                        div4.attr("class", "black-block");
                        var span7 = $("<span>");
                        span7.html("日期：" );
                        span7.appendTo(div4);
                        var span8 = $("<span>");
                        sssj = sssj.replace(/\s/g,"");
                        var sj = sssj.substr(8,sssj.length);
                        sssj = sssj.substr(0,8);
                        var str;
                        var date;
                        if(StringUtils.isEmpty(sssj)){
                            str = sssj;
                        }else{
                            date = new Date(sssj.replace(/(\d{4})(\d{2})(\d{2})/g,'$1-$2-$3'));
                            str = date.Format("yyyy-MM-dd");
                        }
                        span8.html(str+" "+sj);
                        //span8.html(sssj);
                        span8.appendTo(div4);
                        div4.appendTo(div);

                        div.data("info",result[num]["BGZY"]);
                        div.on("click",function(){
                            var info = $(this).data("info");
                            StoreCache.setCache("jkdaSsjlCache", info+"^^zy");
                            $.QuickUrlUtils.redirectJSBridge({url:jkda_view+"/ssjl/ssjlDetail.ejs", title:"手术记录详情"});
                            // $.QuickUrlUtils.redirectJSBridge({url:jkda_view+"/toJkdaSsjlDetail.html", title:"手术记录详情"});
                        });
                        div.appendTo(li);

                        lis.push(li);
                        // });
                    }
                });
            }else{
                var li= $("<li>");
                var div0 = $("<div>");
                div0.attr("class", "black-block");

                div0.attr("style","width:100%;text-align:center; font-weight:bold;color:#000;padding-top:20px");
                div0.html("暂无信息");

                div0.appendTo(li);

                lis.push(li);
            }
            $("#ssjl").html(lis);
        }

        var cfg_def = {
            indata: indata,
            queryJkdaJyjlBack: queryJkdaJyjlBack,
            sortNumber: sortNumber,
            appendToSsjl: appendToSsjl,
        }

        page_ssjl.init = function(cfg){
            $.extend(page_ssjl, cfg_def, cfg);
            page_ssjl.indata();

        }

        return page_ssjl;
    })(jQuery, {});
    

</script>
</html>